<script setup>
import {ipc, isEE} from '@/utils/ipcRenderer'
import {onMounted, ref} from "vue";
import FuncMenu from "@/views/home/sub/funcMenu.vue";
import {getImageUrl} from "@/utils/tools";

const activeMenu = ref('procure')

const menuSelect = (index, indexPath, item) => {
  console.log(index, indexPath, item)
  activeMenu.value = index
}



const procureMap = [
  {
    label: '采购单',
    icon: getImageUrl('procure.svg'),
    route: '#/procure'
  },
  {
    label: '入仓单',
    icon: getImageUrl('storehouse.svg')
  },
  {
    label: '入仓退货',
    icon: getImageUrl('procureRestore.svg')
  }
]


onMounted(() => {
  isEE && ipc.invoke('controller.example.test')

  console.log(procureMap, 'procureMap')
})
</script>

<template>
  <div class="home-main">
    <div class="menu-side">
      <el-menu @select="menuSelect">
        <el-menu-item index="procure"><el-icon><EditPen /></el-icon>采购</el-menu-item>
        <el-menu-item index="sale"><el-icon><Box /></el-icon>出货</el-menu-item>
        <el-menu-item>存货</el-menu-item>
        <el-menu-item>往来</el-menu-item>
      </el-menu>
    </div>
    <div class="right-side">
      <div class="title">顺丰进销存系统</div>
      <div class="content">
        <func-menu v-if="activeMenu === 'procure'" :route-map="procureMap"></func-menu>
        <func-menu v-if="activeMenu === 'sale'" :route-map="procureMap"></func-menu>
      </div>
    </div>
  </div>
</template>

<style scoped lang="less">
.home-main {
  display: flex;
  height: 100vh;
}
.menu-side {
  width: 100px;
  height: 100vh;
  background-color: #c1c1c1;
  :deep(.el-menu) {
    background-color: transparent;
  }
  :deep(.el-menu-item) {
    color: #541514;
    &.is-active {
      background-color: #e0dddd;
    }
  }
}
.right-side {
  width: 100%;
  background-color: #f5f7fa;
  .title {
    width: 100%;
    text-align: center;
    font-size: 25px;
    margin-top: 20px;
    color: #2836cb;
  }
}
</style>
